package com.hst.capacity.application.biz.impl;

import com.hst.capacity.application.biz.FranchiseeBiz;
import com.hst.capacity.application.biz.StatisticsBiz;
import com.hst.capacity.domain.model.entity.franchisee.customer.CustomerFranchiseeEntity;
import com.hst.capacity.domain.model.entity.statistics.StatisticsDailyEntity;
import com.hst.capacity.domain.model.request.specialcar.SpCarSettlementViewListParam;
import com.hst.capacity.domain.model.request.statistics.StatisticsParam;
import com.hst.capacity.domain.model.response.PagingResultVO;
import com.hst.capacity.domain.model.response.specialcar.SpSettlementViewVO;
import com.hst.capacity.domain.model.response.statistics.StatisticsDailyVO;
import com.hst.capacity.domain.service.StatisticsService;
import com.hst.capacity.infra.persistence.jpa.statistics.StatisticsDailyRepository;
import com.hst.capacity.infra.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StatisticsBizImpl implements StatisticsBiz {

    @Autowired
    private StatisticsService statisticsService;

    @Autowired
    FranchiseeBiz franchiseeBiz;

    /**
     * 获取运营商运营城市Code
     * @param param
     * @return
     */
    @Override
    public PagingResultVO<StatisticsDailyVO> findStatisticsDailyLst(StatisticsParam param) {
        String idFranchiseeArr = franchiseeBiz.findIdFranArrByDispacther(param.getIdUser());
        if (StringUtil.isNotBlank(idFranchiseeArr)) {
            param.setIdFranchiseeArr(idFranchiseeArr);
            param.setIdFranchisee(null);
        } else {
            idFranchiseeArr = franchiseeBiz.findIdFranArrByFinance(param.getIdUser());
            if (StringUtil.isNotBlank(idFranchiseeArr)) {
                param.setIdFranchiseeArr(idFranchiseeArr);
                param.setIdFranchisee(null);
            }
        }
        return statisticsService.findStatisticsDailyLst(param);
    }

    @Override
    public StatisticsDailyVO getStatisticsDataOne(StatisticsParam param) {
        String idFranchiseeArr = franchiseeBiz.findIdFranArrByDispacther(param.getIdUser());
        if (StringUtil.isNotBlank(idFranchiseeArr)) {
            param.setIdFranchiseeArr(idFranchiseeArr);
            param.setIdFranchisee(null);
        } else {
            idFranchiseeArr = franchiseeBiz.findIdFranArrByFinance(param.getIdUser());
            if (StringUtil.isNotBlank(idFranchiseeArr)) {
                param.setIdFranchiseeArr(idFranchiseeArr);
                param.setIdFranchisee(null);
            }
        }
        return statisticsService.getStatisticsDataOne(param);
    }

}
